-- sign_in
-- Created by chengb Oct/20/2015
-- 成就：签到

-- 内部函数声明
local whenSignIn;

-- 注册签到的回调
EventMgr.register("google_achievement/sign_in", event.SIGN_IN_BONUS, function(args)
    whenSignIn(args);
end);

-- 注册签到的回调
whenSignIn = function(args)
    -- 判断是否是符合要求的成就
    local function isValidId(id)
        if true == GoogleAchievementM.isCompleted(id) then
            -- 已经完成了
            return false;
        end
        
        return true;
    end
    
    -- 遍历所有的子规则
    local ids = GoogleAchievementM.getIdsByRule("sign_in");
    for _, id in pairs(ids) do
        if isValidId(id) then
            -- 尝试完成成就
            GoogleAchievementM.tryComplete(id, 1);
        end
    end
end

